//
//  Intervention+intervention.m
//  ClinicalCollections
//
//  Created by janakiraman gopinath on 5/18/13.
//  Copyright (c) 2013 GOPI. All rights reserved.
//

#import "Intervention+intervention.h"

@implementation Intervention (intervention)

+ (void) intervention:(NSArray *) interventions
           forContext:(NSManagedObjectContext *)context
  forClinicalTrialGov:(ClinicalTrialGov *)clinicalTrialGov
{
    for (NSDictionary *interventionDict in interventions) {
        Intervention  *intervention = (Intervention *)[NSEntityDescription insertNewObjectForEntityForName:@"Intervention"
                                                                                    inManagedObjectContext:context];
        intervention.name = [interventionDict valueForKey:@"intervention_name"];
        if (!([[interventionDict valueForKey:@"description"] isEqual:[NSNull null]]))
            intervention.desc = [interventionDict valueForKey:@"description"];

        intervention.type = [interventionDict valueForKey:@"intervention_type"];
        intervention.clinicalTrialGov = clinicalTrialGov;
        NSLog(@"Intervention Name %@" , intervention.name);
        NSLog(@"Intervention desc %@" , intervention.desc);
        NSLog(@"Intervention tyoe %@" , intervention.type);
        [[ArmGroupLabel class] armGroupLabel:[interventionDict valueForKey:@"arm_group_label"]
                                  forContext:context
                             forIntervention:intervention];
        [[OtherName class] otherName:[interventionDict valueForKey:@"other_name"]
                          forContext:context
                     forIntervention:intervention];
        
        
    }
    return;
}
@end
